1. Field of the Invention
The present invention relates to a microcomputer, such as a microcontroller, which contains a flash memory.
2. Description of the Background Art
Conventionally, in a microcontroller (microcomputer) with a built-in flash memory, the contents stored in the flash memory are generally erased and written by a CPU in the two situations shown below.
In a first situation, the rewriting is achieved while no user program is running in the microcontroller. The microcontroller itself is placed in the stopped state and the contents stored in the flash memory are rewritten by external rewriting equipment, such as a flash writer, through an interface for flash rewrite control. Alternatively, a specialized program for rewriting the flash memory is run and the contents stored in the flash memory are rewritten by utilizing an interface of a serial communication function.
In a second situation, the rewriting is accomplished by using a function as the microcontroller. While the microcontroller is operating, the contents stored in the flash memory are rewritten in the background with a rewrite program stored in the flash memory in the microcontroller.
Rewriting in the second situation includes a first method in which the flash rewrite program stored in the flash memory is transferred to an additional RAM provided in the microcontroller and then run on the RAM.
Rewriting in the second situation also includes a second method, where a control circuit capable of background processing is provided in hardware.
The second method is now described with an example. The second method requires circuitry for controlling the flash memory. That is, while a certain block in a flash memory, which is divided into blocks, is undergoing erase/write processing, the flash memory control circuitry allows the CPU, in parallel, to read and execute a program stored on the flash memory in a block or blocks other than the block being rewritten.
Specifically, rewriting (writing/erasing) and reading in parallel requires that the potential generating circuitry in the flash memory circuit block include two systems for writing/erasing and normal reading. This necessitates an increased area and causes the control circuitry, such as a microsequencer, to be configured complicatedly.
In the first situation, there is a problem that the flash memory cannot be rewritten while the microcontroller is actually being used after mounted by soldering etc. in the user system. Applications in some fields of the microcontroller with built-in flash memory may expect data to be rewritten while the microcontroller is being used. This method, which cannot be used under such conditions, is therefore disadvantageous.
The first and second methods capable of rewriting in the second situation are intended to solve this problem.
The first method, however, requires previously transferring the program from the flash memory to the RAM, which is disadvantageous because it imposes a transfer workload on the CPU and requires RAM capacity for the CPU rewrite program.
Also, in the second method which uses control circuitry capable of background processing, rewriting the memory in the background without interrupting operation of the microcontroller requires complicated control circuitry as stated above.
This requires larger control circuitry per same memory capacity as compared with a chip having no background rewriting function. Complicated control circuitry in a semiconductor integrated circuit necessitates an increased area, leading to an increased cost.